package com.xbongbong.saas.enums.dictionary;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * 退货单的订单状态枚举
 * @author feng.zheng
 */
@Getter
public enum RefundOrderStatusEnum {


    // 审核中
    APPROVAL("1","enum.refundOrderStatus.name.approval","approval"),
    // 已作废
    ABOLISHED("2","enum.refundOrderStatus.name.abolished","abolished"),
    // 处理中
    HANDLE("3","enum.refundOrderStatus.name.handle","handle"),
    // 已完成
    COMPLETED("4","enum.refundOrderStatus.name.completed","completed"),
    //已关闭
    CLOSED("5","enum.refundOrderStatus.name.closed","closed")
    ;
    private String code;
    private String name;
    private String attr;


    RefundOrderStatusEnum(String code, String name, String attr) {
        this.code = code;
        this.name = name;
        this.attr = attr;
    }
    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }



    public static RefundOrderStatusEnum getByCode(String code) {
        for (RefundOrderStatusEnum orderStatusEnum : RefundOrderStatusEnum.values()) {
            if (Objects.equals(orderStatusEnum.getCode(), code)) {
                return orderStatusEnum;
            }
        }
        return RefundOrderStatusEnum.APPROVAL;
    }
}
